//
//  BidInvestRecordListViewModel.swift
//  cxd4iphone
//
//  Created by hexy on 12/23/15.
//  Copyright © 2015 hexy. All rights reserved.
//

import UIKit
import ReactiveCocoa

class BidInvestRecordListViewModel: BaseTableListViewModel {

    func loadBidList(bidId: String, pullDown: Bool) -> RACSignal {
        
        return RACSignal.createSignal({ (subscriber) -> RACDisposable! in
            
            APIManager.loadBidInvestRecords(bidId, page: 1).subscribeNext({ (result) -> Void in
                
                xx_JsonPrint(dict: result)
                let array = result as! [[String: AnyObject]]
                
                var arrM = [BidInvestRecordCellViewModel]()
                for dict in array {
                    
                    arrM.append(BidInvestRecordCellViewModel(bidInvestRecordModel: BidInvestRecordModel(dict: dict)))
                }
                
                self.sections = [arrM]
                subscriber.sendCompleted()
                
                }, error: { (error) -> Void in
                    
                    subscriber.sendError(error)
            })

            return RACDisposable(block: {})
        })
    }

    
}
